{% extends 'base.html' %}
{% block styles %}
    {{ super() }}
    <!-- 验证样式 -->
    <link rel="stylesheet" href="{{ url_for('static',filename='bootstrap_validator/bootstrap-validator.css') }}">
{% endblock %}

{% block title %}修改密码{% endblock title %}
{% block content %}
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                个人中心
                <small>修改密码</small>
            </h1>
        </section>
        <section class="content">
            <div class="row">
                <div class="col-md-6">
                    <section class="content container-fluid">
                        <div class="box box-primary">
                            <div class="box-header with-border">
                                <h3 class="box-title">修改密码</h3>
                            </div>
                            <!-- /.box-header -->
                            <!-- form start -->
                            <form id="rest" action="{{ url_for('auth.resetpw') }}" method="post">
                                <div class="box-body">
                                    <div class="form-group">
                                        <label for="exampleInputEmail1">原密码</label>
                                        <input id="oldpassword" type="password" class="form-control" placeholder="旧密码"
                                               name="oldpassword">
                                    </div>
                                    <div class="form-group">
                                        <label for="exampleInputPassword1">新密码</label>
                                        <input id="newpassword" type="password" class="form-control" placeholder="新密码"
                                               name="newpassword">
                                        {% for message in get_flashed_messages() %}
                                            <span class="help-block text-red">{{ message }}</span>
                                        {% endfor %}
                                    </div>
                                </div>
                                <!-- /.box-body -->
                                <div class="box-footer">
                                    <div class="form-group">
                                        <button type="submit" class="btn btn-primary">修改密码</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </section>
                </div>
            </div>
        </section>
    </div>
{% endblock %}
{% block scripts %}
    {{ super() }}
    <!-- 验证样式validator的js -->
    <script src="{{ url_for('static',filename="bootstrap_validator/bootstrap-validator.js") }}"></script>
    <script>
        //验证表单
        $(function () {
            $("#rest").bootstrapValidator({
                message: '这个值是无效的',
                feedbackIcons: {
                    /*input状态样式图片*/
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    oldpassword: {
                        message: '密码验证失败',
                        validators: {
                            notEmpty: {
                                message: '密码不能为空'
                            },
                            regexp: {
                                regexp: /^[a-zA-Z0-9_\.]+$/,
                                message: '只能由字母、数字、点和下划线'
                            }
                        }
                    },
                    newpassword: {
                        message: '密码验证失败',
                        validators: {
                            notEmpty: {
                                message: '密码不能为空'
                            },
                            regexp: {
                                regexp: /^[a-zA-Z0-9_\.]+$/,
                                message: '只能由字母、数字、点和下划线'
                            }
                        },
                    }
                }
            });
        });
    </script>
{% endblock scripts %}